package com.ys.controller.web.sys;

import com.ys.config.MenuId;
import com.ys.entity.sys.TbCompanyInfo;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.W;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Controller
@RequestMapping("/web/sys/tbCompanyInfo")
public class WebTbCompanyInfoController {
	

	@Autowired
	private CommonApiService<TbCompanyInfo> commonApiService;


	/*
	 * 编辑
	 */
	@GetMapping("/toEdit")
	public String toEdit(Model model, HttpServletRequest request, HttpServletResponse response,@RequestParam Map<String, Object> params){
		if (params.get("id") == null){
			return W.error(model, "id不能为空");
		}

		Long id = Long.valueOf((params.get("id").toString()));

		if (new TbCompanyInfo().setId(id).count() == 0){
			return W.error(model, "该公司信息不存在!");
		}

		try {
			return commonApiService.toEdit(model, id, new TbCompanyInfo(), MenuId.TB_CompanyInfo, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, "数据有误，请联系客服");
		}
	}

}
